IP Manager
Owner: Nuwan Danushka
Introduction
IpManager reads the client's and the server's IP addresses from the server environment ($_SERVER). Both methods are static:
$client_ip = Util::IpManager()::get_client_ip();
IP Manager Methods
get_client_ip
Description:
The get_client_ip method returns the client's IP address. It checks these $_SERVER entries in order and returns the first one that is set: HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, HTTP_X_FORWARDED, HTTP_FORWARDED_FOR, HTTP_FORWARDED, REMOTE_ADDR.
Syntax:
Util::IpManager()::get_client_ip();
Return Value:
String: The value of the first entry found, returned as is.null: None of the entries is set, for example in a shell or heartbeat run.
get_server_ip
Description:
The get_server_ip method returns the server's IP address from $_SERVER['SERVER_ADDR'].
Syntax:
Util::IpManager()::get_server_ip();
Return Value:
String: The server's IP address.null:SERVER_ADDRis not set or is empty, for example in a shell run.